package com.hmall.item.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hmall.item.mapper.ItemMapper;
import com.hmall.item.pojo.Item;
import com.hmall.item.service.IItemService;
import java.util.Date;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;


@Service
@RequiredArgsConstructor
public class ItemServiceImpl extends ServiceImpl<ItemMapper, Item> implements IItemService {

    private final ItemMapper itemMapper;

    @Override
    public void selectPage(Page<Item> page, Object o) {
        itemMapper.selectPage(page,null);
    }

    @Override
    public Item selectById(Long id) {
        return itemMapper.selectById(id);
    }

    @Override
    public void insert(Item item) {
        item.setCreateTime(new Date());
        item.setUpdateTime(new Date());
        itemMapper.insert(item);
    }

    @Override
    public void delete(Long id) {
        itemMapper.deleteById(id);
    }

    @Override
    public void updateItem(Item item) {
        item.setUpdateTime(new Date());
        itemMapper.updateById(item);
    }
}

